#include <sys/ipc.h>
#include <sys/shm.h>
#include <ctime>
#include <unistd.h>
#include <iostream>

using namespace std;

// int main()
// {
//     int shmid = shmget(1,4096,IPC_CREAT|0666);
//     return 0;
// }

// int main()
// {
//     int id = shmget(1, 4096, IPC_CREAT | IPC_EXCL | 0666);

//     struct shmid_ds shm;

//     shmctl(id, IPC_STAT, &shm);

//     cout << "atime: " << shm.shm_atime << endl;
//     cout << "ctime: " << shm.shm_ctime << endl;
//     cout << "cpid: " << shm.shm_cpid << endl;

//     return 0;
// }

// int main()
// {
//     int id = shmget(1, 4096, IPC_CREAT | IPC_EXCL | 0666);

//     //修改共享内存属性需要先通过IPC_STAT填充一个shmid_ds结构体
//     struct shmid_ds shm_desc;
//     shmctl(id, IPC_STAT, &shm_desc);
//     cout << "ctime:" << shm_desc.shm_ctime << endl;

//     //修改权限
//     shm_desc.shm_perm.mode = 0644;
//     sleep(5);
//     shmctl(id, IPC_SET, &shm_desc);

//     //重新获取shm信息
//     shmctl(id, IPC_STAT, &shm_desc);
//     cout << "ctime:" << shm_desc.shm_ctime << endl;

//     return 0;
// }

// int main()
// {
//     shmctl(5,IPC_RMID,nullptr);
//     return 0;
// }

int main()
{
    key_t key=ftok(".",1);
    cout<<key<<endl;;

    return 0;
}